/*Importing dataset into SAS*/

PROC IMPORT OUT= WORK.ACSTLC4 
            DATAFILE= "H:\ACS TLC 2021\Data\ACS TLC data PL 11.2.22-V4-i
neligibles excluded and RN & LPNs removed.sav" 
            DBMS=SPSS REPLACE;

RUN;


/*Running frequencies on variables of interest*/

proc freq data=work.ACSTLC3;
tables Sec2_Q16 Screenpracs_2021collapsed HPVvaccin_9_10collapsed race_eth_collapsed age_collapsedV2 gender_RC region_new train_special3;
run;

proc freq data=work.ACSTLC3;
tables train_collapsed specialty_collapsed region_new;
run;




/*manual forward*/
/*models with 1 variable*/
title 'Model 2-2021 screening pracs age only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = age_collapsedV2;
exact age_collapsedV2/estimate=both;
run;


title 'Model 2-2021 screening pracs race only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = race_eth_collapsed;
exact race_eth_collapsed/estimate=both;
run;


title 'Model 2-2021 screening pracs gender only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = gender_RC;
exact gender_RC/estimate=both;
run;


title 'Model 2-2021 screening pracs region only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = region_new;
exact region_new/estimate=both;
run;


title 'Model 2-2021 screening pracs train only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = train_collapsed;
exact train_collapsed/estimate=both;
run;


title 'Model 2-2021 screening pracs specialty only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = specialty_collapsed;
exact specialty_collapsed/estimate=both;
run;

//*specialty sig. at .0567*//


//*Models with 3 vars*//
title 'Model 2-2021 screening pracs specialty plus age';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = specialty_collapsed age_collapsedV2;
exact specialty_collapsed age_collapsedV2/estimate=both;
run;


title 'Model 2-2021 screening pracs specialty plus race';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = specialty_collapsed race_eth_collapsed;
exact specialty_collapsed race_eth_collapsed/estimate=both;
run;



title 'Model 2-2021 screening pracs specialty plus gender';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = specialty_collapsed gender_RC;
exact specialty_collapsed gender_RC/estimate=both;
run;


title 'Model 2-2021 screening pracs specialty plus region';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = specialty_collapsed region_new;
exact specialty_collapsed region_new/estimate=both;
run;


title 'Model 2-2021 screening pracs specialty plus train';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Screenpracs_2021collapsed = specialty_collapsed train_collapsed;
exact specialty_collapsed train_collapsed/estimate=both;
run;


*check automated forward selection: didn't fit exact but selected only specialty;

proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref ref=first order=freq;
model Screenpracs_2021collapsed = age_collapsedV2 race_eth_collapsed gender_RC region_new train_collapsed specialty_collapsed/selection=f slentry=0.1;
exact age_collapsedV2 race_eth_collapsed gender_RC region_new train_collapsed specialty_collapsed/estimate=both;
run;


*check automated backward selection: didn't fit exact but again selected only specialty;
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref ref=first order=freq;
model Screenpracs_2021collapsed = age_collapsedV2 race_eth_collapsed gender_RC region_new train_collapsed specialty_collapsed/selection=b SLSTAY=0.1;
exact age_collapsedV2 race_eth_collapsed gender_RC region_new train_collapsed specialty_collapsed/estimate=both;
run;



//*final model for convenience*//
title 'Model 2-2021 screening pracs';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref ref=first order=freq;
model Screenpracs_2021collapsed= train_collapsed specialty_collapsed race_eth_collapsed;
exact train_collapsed specialty_collapsed race_eth_collapsed/estimate=both;
run; 
//*specialty sig. at .0364
training sig. at .0605
race/ethnicity sig. at .0873*//





title 'Model 3-Pandemic impact on CC screening, tracking, etc.';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Sec2_Q16 = race_eth_collapsed age_collapsedV2 gender_RC region_new train_collapsed specialty_collapsed;
exact race_eth_collapsed age_collapsedV2 gender_RC region_new train_collapsed specialty_collapsed/estimate=both;
run;




*Running manual forward selection*

/*manual forward*/
/*models with 1 variable*/
title 'Model 3-Pandemic impact on CC screening, tracking, etc. age only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2/param=ref ref=first order=freq;
model Sec2_Q16 = age_collapsedV2;
exact age_collapsedV2 /estimate=both;
run; 


title 'Model 3-Pandemic impact on CC screening, tracking, etc. race only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2/param=ref ref=first order=freq;
model Sec2_Q16 = race_eth_collapsed;
exact race_eth_collapsed /estimate=both;
run; 


title 'Model 3-Pandemic impact on CC screening, tracking, etc. gender only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 /param=ref ref=first order=freq;
model Sec2_Q16 = gender_RC ;
exact gender_RC /estimate=both;
run; 


title 'Model 3-Pandemic impact on CC screening, tracking, etc. region only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2/param=ref ref=first order=freq;
model Sec2_Q16 = region_new ;
exact region_new /estimate=both;
run; 


title 'Model 3-Pandemic impact on CC screening, tracking, etc. train only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Sec2_Q16 = train_collapsed;
exact train_collapsed /estimate=both;
run; 
//*training sig at .0856*//



title 'Model 3-Pandemic impact on CC screening, tracking, etc. specialty only';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Sec2_Q16 = specialty_collapsed;
exact specialty_collapsed /estimate=both;
run; 




//*Models with 3 vars*//
title 'Model 3-Pandemic impact on CC screening, tracking, etc. training plus age';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Sec2_Q16 = train_collapsed age_collapsedV2;
exact train_collapsed age_collapsedV2/estimate=both;
run;


//*Models with 3 vars*//
title 'Model 3-Pandemic impact on CC screening, tracking, etc. training plus race';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Sec2_Q16 = train_collapsed race_eth_collapsed;
exact train_collapsed race_eth_collapsed/estimate=both;
run;


//*Models with 3 vars*//
title 'Model 3-Pandemic impact on CC screening, tracking, etc. training plus gender';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Sec2_Q16 = train_collapsed gender_RC;
exact train_collapsed gender_RC/estimate=both;
run;


//*Models with 3 vars*//
title 'Model 3-Pandemic impact on CC screening, tracking, etc. training plus region';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Sec2_Q16 = train_collapsed region_new;
exact train_collapsed region_new/estimate=both;
run;



//*Models with 3 vars*//
title 'Model 3-Pandemic impact on CC screening, tracking, etc. training plus specialty';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref;
model Sec2_Q16 = train_collapsed specialty_collapsed;
exact train_collapsed specialty_collapsed/estimate=both;
run;



*check automated forward selection;
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed (ref= "MD/DO") specialty_collapsed (ref="OBGYN/Women's Health") region_new (ref="Northeast")/param=ref ref=first order=freq;
model Sec2_Q16 = age_collapsedV2 race_eth_collapsed gender_RC region_new train_collapsed specialty_collapsed/selection=f slentry=0.1;
exact age_collapsedV2 race_eth_collapsed gender_RC region_new train_collapsed specialty_collapsed/estimate=both;
run;


*check automated backward selection;
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed (ref="MD/DO") specialty_collapsed (ref= "OBGYN/Women's Health") region_new (ref="Northeast")/param=ref ref=first order=freq;;
model Sec2_Q16 = age_collapsedV2 race_eth_collapsed gender_RC region_new train_collapsed specialty_collapsed/selection=b SLSTAY=0.1 ;
exact age_collapsedV2 race_eth_collapsed gender_RC region_new train_collapsed specialty_collapsed/estimate=both;
run;



*Repeat final model for convenience;
title 'Model 3-Pandemic impact on CC screening, tracking, etc. training only: Final';
proc logistic data=work.ACSTLC3 desc;
class train_collapsed (ref= "MD/DO")/param=ref ref=first order=freq;;
model Sec2_Q16 = train_collapsed;
exact train_collapsed/estimate=both;
run; 





*Code for creation of 2021 screening practices model plot to be used in manuscript*

title 'Model 2-2021 screening pracs';
proc logistic data=work.ACSTLC3 desc;
class age_collapsedV2 train_collapsed(ref= "MD/DO")specialty_collapsed (ref= "OBGYN/Women's Health")region_new (ref="Northeast")/param=ref ref=first order=freq;
model Screenpracs_2021collapsed= train_collapsed specialty_collapsed race_eth_collapsed;
exact train_collapsed specialty_collapsed race_eth_collapsed/estimate=both;
run; 


ods output "Odds Ratios"=orci;
proc logistic data=work.ACSTLC4 descending;
class age_collapsedV2 training(ref= "MD/DO")specialty (ref= "OBGYN/WH")region_new (ref="Northeast")/param=ref ref=first order=freq;
model Screenpracs_2021collapsed= training specialty race_ethnicity;
exact training specialty race_ethnicity/estimate=both;
run; 

data orci;set orci;
effect=upcase(effect);
run;



title "Clinician & Practice characteristics associated with odds of reporting conducting the same amount or more cervical cancer screening now/in 2021 vs before the pandemic";
proc sgplot data=orci;
 scatter x=oddsratioest y=effect / xerrorlower=lowercl
xerrorupper=uppercl
markerattrs=or
(symbol=DiamondFilled size=8);
 refline 1 / axis=x;

 xaxis label="OR and 95% CI " min=0;
 yaxis label="Covariates";

run;
